/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.collections.tuples;

import static com.softwarecraftsmen.collections.tuples.Singleton.singleton;
import static com.softwarecraftsmen.collections.tuples.Pair.pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class EmptyTuple extends AbstractTuple
{
	private static final EmptyTuple SingletonInstance = new EmptyTuple();

	private EmptyTuple()
	{
		super();
	}

	@NotNull
	public static EmptyTuple emptyTuple()
	{
		return SingletonInstance;
	}

	@NotNull
	public <A> Singleton<A> append(@NotNull final A a)
	{
		return singleton(a);
	}

	@NotNull
	public <A, B> Pair<A, B> append(@NotNull final A a, @NotNull final B b)
	{
		return pair(a, b);
	}

	@NotNull
	public Object valueAt(final Integer index)
	{
		guardValueAt(index);
		throw new IllegalStateException();
	}

	public int size()
	{
		return 0;
	}

	@NotNull
	public String toString()
	{
		return "()";
	}

	public boolean equals(final @Nullable Object o)
	{
		return o != null && (o.getClass().equals(getClass()));
	}

	public int hashCode()
	{
		return 498342423;
	}

	@NotNull
	public EmptyTuple slice()
	{
		return this;
	}
}
